﻿namespace LiteBlog.Common.Entities
{
    using LiteBlog.Common.Enums;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel.DataAnnotations;

    public class PostInfo
    {
        public string FileID { get; set; }

        [Required(ErrorMessage = "Please enter a title")]
        public string Title { get; set; }

        public string Author { get; set; }
        public DateTime Time { get; set; }
        public DateTime UpdatedTime { get; set; } // only for feeds & meta section
        public string FormattedTime { get; set; }
        public List<Category> Categories { get; set; }
        public IEnumerable<Tag> Tags { get; set; }
        public PostType Type { get; set; }
        public int Views { get; set; }

        public PostInfo()
        {
            Categories = new List<Category>();
            Tags = new List<Tag>();
        }

        #region Convenience properties

        public string MonthId
        {
            get
            {
                return ArchiveMonth.GetMonthId(Time);
            }
        }

        public int Month
        {
            get { return Time.Month; }
        }

        public int Year
        {
            get { return Time.Year; }
        }

        #endregion
    }
}